﻿using University.Workshop.DataAccess;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using University.Workshop.Business;
using System.Data;
using University.Workshop.Model;

namespace University.Workshop.Tests
{
    [TestClass()]
    public class ProductDataAccessTest
    {

        private TestContext testContextInstance;
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        [TestMethod()]
        public void AddProductTest()
        {
            Random ran = new Random();
            int num = ran.Next(10000);
            Product product = new Product()
            {
                CodeProduct = num.ToString(System.Globalization.CultureInfo.CurrentCulture),
                NameProduct="Resfrianex",
                Presentation="Tableta",
                CodeProvider="prov111",              
                DateAdmission=DateTime.Now,
                State="A"
            }; 
            bool expected = true; 
            bool actual;
            actual = ProductDataAccess.AddProduct(product);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void ValidateProductTest()
        {
            string code = "med001"; 
            bool expected = false; 
            bool actual;
            actual = ProductDataAccess.ValidateProduct(code);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void EditProductDataTest()
        {
            Product product = new Product()
            {
                CodeProduct = "med001",
                NameProduct = "Resfrianex",
                Presentation = "Tableta",
                CodeProvider = "prov111",
                DateAdmission = DateTime.Now,
                State = "A"
            };
            bool expected = true;
            bool actual;
            actual = ProductDataAccess.EditProductData(product);
            Assert.AreEqual(expected, actual);
            
            
        }

        [TestMethod()]
        public void DeleteProductDataTest()
        {
            string value = "med001"; 
            bool expected = true; 
            bool actual;
            actual = ProductDataAccess.DeleteProductData(value);
            Assert.AreEqual(expected, actual);
            
        }

        [TestMethod()]
        public void HabilityProductDataTest()
        {
            string value = "med001";
            bool expected = true; 
            bool actual;
            actual = ProductDataAccess.EnableProducts(value);
            Assert.AreEqual(expected, actual);
            
        }

     
        [TestMethod()]
        public void LookProductsTest()
        {
            string value = "med001";
            DataTable actual;
            actual = ProductDataAccess.LookProducts(value);
            Assert.IsNotNull( actual);
        }

        [TestMethod()]
        public void QuantityAndPriceTest()
        {
            string code = "000000"; 
            DataTable expected = null; 
            DataTable actual;
            actual = ProductDataAccess.QuantityAndPrice(code);
            Assert.AreNotEqual(expected, actual);
        }

        [TestMethod()]
        public void ReportProductAscendentTest()
        {
            DataTable expected = null; 
            DataTable actual;
            actual = ProductDataAccess.ReportProductAscendent();
            Assert.AreNotEqual(expected, actual);
        }

        [TestMethod()]
        public void PresentationProductTest()
        {
            string code = "00000000"; 
            DataTable expected = null; 
            DataTable actual;
            actual = ProductDataAccess.PresentationProduct(code);
            Assert.AreNotEqual(expected, actual);
        }
    }
}
